/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import flightlifter.WiringNode;

/**
 *
 * @author Matt
 */
public class AbsoluteLayout extends GUILayout {



    public AbsoluteLayout(GUI parent) {
        setParent(parent);
        cWidth = 150;
    }

    protected void doLayout() {
    }

    public void add(GUIComponent toAdd) {
        toAdd.setParent(parent);

        VerticalLayout temp;
        if (toAdd instanceof WiringNode){
            WiringNode wn = (WiringNode)toAdd;
             temp = new VerticalLayout(parent, wn.locX, wn.locY, cWidth, null);
        }
        else{
            temp = new VerticalLayout(parent, 200, 200, cWidth, null);
        }

        temp.add(toAdd);
        guiComponents.add(temp);
        temp.doLayout();
    }

    public void draw() {
        GUIComponent temp;
        for (int i = 0; i < guiComponents.size(); i++) {
            temp = (GUIComponent) guiComponents.elementAt(i);
            temp.draw();
        }
    }

        /**
     * Handle mouse presses.
     * @return integer indicating whether the mouse event affected the layout.
     */
    public int mousePressed(int mouseX,int mouseY) {

        GUIComponent temp;

                for (int i = 0; i < guiComponents.size(); i++) {
                    temp = (GUIComponent) guiComponents.elementAt(i);
                    if (temp.mousePressed(mouseX,mouseY) == 1) {
                        //they've clicked on a component
                        //if it isn't a submenu, hide this menu
                       /*
                        if (isSubMenu == 1 && !(temp instanceof SGMenu)) {
                            setVisible(0);
                        }
                        */
                        return 1;
                    }
                }

        return 0;
    }


}
